import 'package:flutter/material.dart';

main() {
  runApp(Demo61App());
}

class Demo61App extends StatefulWidget {
  const Demo61App({Key? key}) : super(key: key);

  @override
  _Demo61AppState createState() => _Demo61AppState();
}

class _Demo61AppState extends State<Demo61App> {
  List<Tab> tabs = [
    Tab(
      text: '关注1',
    ),
    Tab(
      text: '热门1',
    ),
    Tab(
      text: '科技1',
    ),
    Tab(
      text: '搞笑1',
    ),
    Tab(
      text: '社会1',
    ),
    Tab(
      text: '法律1',
    ),
    Tab(
      text: '人文1',
    ),
  ];

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: DefaultTabController(
        length: tabs.length,
        child: Scaffold(
          appBar: AppBar(
            title: Row(
              mainAxisAlignment: MainAxisAlignment.center,
              children: [
                Expanded(
                    child: TabBar(
                  tabs: tabs,
                  isScrollable: true,
                ))
              ],
            ),

            // bottom: TabBar(
            //   tabs: tabs,
            //   isScrollable: true,
            // ),
          ),
          body: TabBarView(
            children: tabs.map((e) {
              return Center(
                child: Text(e.text ?? "其他"),
              );
            }).toList(),
          ),
        ),
      ),
    );
  }
}
